package com.webchat.domain.vo.response;

import com.alibaba.nacos.common.utils.CollectionUtils;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @Author: 程序员王七七 https://www.coderutil.com 网站作者
 * @Date: 2021-7-11 0011 14:37
 * @Description: 无描述信息
 */
@Data
public class MomentResponseDetailVO extends MomentResponseBaseVO {

    private String statusDesc;

    private Long commentCount = 0L;

    /***
     * 是否有删除权限
     */
    private Boolean hasDeleteAuth = false;

    private UserBaseResponseInfoVO userInfo;

    private List<UserBaseResponseInfoVO> likeUsers;

    /***
     * 外显评论
     */
    private List<CommentOutResponseVO> outComments;

    public boolean getHasImage() {
        return StringUtils.isNotBlank(super.getImages());
    }

    public String getFirstImage() {
        List<String> images = getImageList();
        if (CollectionUtils.isNotEmpty(images)) {
            return images.get(0);
        }
        return null;
    }

    public List<String> getImageList() {
        if (getHasImage()) {
            return new ArrayList<>(Arrays.asList(super.getImages().split(",")));
        }
        return new ArrayList<>();
    }

    public boolean getHasVideo() {
        return StringUtils.isNotBlank(super.getVideo());
    }

    public String getPubDateStr() {
        if (super.getPubDate() == null) {
            return "";
        }
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return simpleDateFormat.format(super.getPubDate());
    }

    public Long getPubDateTime() {
        if (super.getPubDate() == null) {
            return 0L;
        }
        return super.getPubDate().getTime();
    }

    public String getStatusDescStr() {
//       return CommonStatusEnum.getStatusDescByStatus(super.getStatus());
       return null;
    }
}
